﻿namespace HRM.CORE.REPORT
{
    using APP.HELPER.Utils.Security;
    using DevExpress.Utils;
    using DevExpress.XtraPrinting;
    using DevExpress.XtraReports.UI;
    using Extra.ERP;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Printing;

    public class rptContract1 : XtraReport
    {
        private BottomMarginBand BottomMargin;
        private IContainer components;
        private DetailBand Detail;
        private FormattingRule formattingRule1;
        private FormattingRule formattingRule2;
        private FormattingRule formattingRule3;
        private FormattingRule formattingRule4;
        private FormattingRule formattingRule5;
        private FormattingRule formattingRule6;
        private FormattingRule formattingRule7;
        private FormattingRule formattingRule8;
        private HRM_CONTRACT l_Contract;
        private string m_ContractCode;
        private string m_EmployeeCode;
        private TopMarginBand TopMargin;
        private XRTableCell txtCompany;
        private XRTableCell txtContractCode;
        private XRRichText xrRichText1;
        private XRTable xrTable1;
        private XRTable xrTable3;
        private XRTableCell xrTableCell10;
        private XRTableCell xrTableCell11;
        private XRTableCell xrTableCell12;
        private XRTableCell xrTableCell3;
        private XRTableCell xrTableCell4;
        private XRTableCell xrTableCell7;
        private XRTableCell xrTableCell8;
        private XRTableCell xrTableCell9;
        private XRTableRow xrTableRow1;
        private XRTableRow xrTableRow2;
        private XRTableRow xrTableRow3;
        private XRTableRow xrTableRow4;

        public rptContract1()
        {
            this.l_Contract = new HRM_CONTRACT();
            this.m_EmployeeCode = "";
            this.m_ContractCode = "";
            this.components = null;
            this.InitializeComponent();
        }

        public rptContract1(string ContractCode, string EmployeeCode)
        {
            this.l_Contract = new HRM_CONTRACT();
            this.m_EmployeeCode = "";
            this.m_ContractCode = "";
            this.components = null;
            this.InitializeComponent();
            this.m_ContractCode = ContractCode;
            this.m_EmployeeCode = EmployeeCode;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(rptContract1));
            this.Detail = new DetailBand();
            this.xrRichText1 = new XRRichText();
            this.formattingRule1 = new FormattingRule();
            this.formattingRule2 = new FormattingRule();
            this.formattingRule3 = new FormattingRule();
            this.formattingRule4 = new FormattingRule();
            this.formattingRule5 = new FormattingRule();
            this.formattingRule7 = new FormattingRule();
            this.formattingRule8 = new FormattingRule();
            this.xrTable1 = new XRTable();
            this.xrTableRow1 = new XRTableRow();
            this.txtCompany = new XRTableCell();
            this.xrTableCell3 = new XRTableCell();
            this.xrTableRow2 = new XRTableRow();
            this.txtContractCode = new XRTableCell();
            this.xrTableCell4 = new XRTableCell();
            this.xrTable3 = new XRTable();
            this.xrTableRow3 = new XRTableRow();
            this.xrTableCell7 = new XRTableCell();
            this.xrTableCell8 = new XRTableCell();
            this.xrTableCell9 = new XRTableCell();
            this.xrTableRow4 = new XRTableRow();
            this.xrTableCell10 = new XRTableCell();
            this.xrTableCell11 = new XRTableCell();
            this.xrTableCell12 = new XRTableCell();
            this.TopMargin = new TopMarginBand();
            this.BottomMargin = new BottomMarginBand();
            this.formattingRule6 = new FormattingRule();
            this.xrRichText1.BeginInit();
            this.xrTable1.BeginInit();
            this.xrTable3.BeginInit();
            this.BeginInit();
            this.Detail.Controls.AddRange(new XRControl[] { this.xrRichText1, this.xrTable1, this.xrTable3 });
            this.Detail.HeightF = 1992f;
            this.Detail.Name = "Detail";
            this.Detail.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.Detail.TextAlignment = TextAlignment.TopLeft;
            this.xrRichText1.CanShrink = true;
            this.xrRichText1.FormattingRules.Add(this.formattingRule1);
            this.xrRichText1.FormattingRules.Add(this.formattingRule2);
            this.xrRichText1.FormattingRules.Add(this.formattingRule3);
            this.xrRichText1.FormattingRules.Add(this.formattingRule4);
            this.xrRichText1.FormattingRules.Add(this.formattingRule5);
            this.xrRichText1.FormattingRules.Add(this.formattingRule7);
            this.xrRichText1.FormattingRules.Add(this.formattingRule8);
            this.xrRichText1.LocationFloat = new PointFloat(2.08327f, 72.58326f);
            this.xrRichText1.Name = "xrRichText1";
            this.xrRichText1.Scripts.OnHtmlItemCreated = "xrRichText1_HtmlItemCreated";
            this.xrRichText1.SerializableRtfString = manager.GetString("xrRichText1.SerializableRtfString");
            this.xrRichText1.SizeF = new SizeF(684.9167f, 1840.375f);
            this.formattingRule1.Name = "formattingRule1";
            this.formattingRule2.Name = "formattingRule2";
            this.formattingRule3.Name = "formattingRule3";
            this.formattingRule4.Name = "formattingRule4";
            this.formattingRule5.Name = "formattingRule5";
            this.formattingRule7.Name = "formattingRule7";
            this.formattingRule8.Name = "formattingRule8";
            this.xrTable1.Font = new Font("Times New Roman", 9.75f, FontStyle.Bold);
            this.xrTable1.LocationFloat = new PointFloat(9.536743E-05f, 0f);
            this.xrTable1.Name = "xrTable1";
            this.xrTable1.Rows.AddRange(new XRTableRow[] { this.xrTableRow1, this.xrTableRow2 });
            this.xrTable1.SizeF = new SizeF(686.9999f, 51.04167f);
            this.xrTable1.StylePriority.UseFont = false;
            this.xrTableRow1.Cells.AddRange(new XRTableCell[] { this.txtCompany, this.xrTableCell3 });
            this.xrTableRow1.Name = "xrTableRow1";
            this.xrTableRow1.Weight = 1.0;
            this.txtCompany.Name = "txtCompany";
            this.txtCompany.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.txtCompany.StylePriority.UsePadding = false;
            this.txtCompany.StylePriority.UseTextAlignment = false;
            this.txtCompany.Text = "txtCompany";
            this.txtCompany.TextAlignment = TextAlignment.MiddleLeft;
            this.txtCompany.Weight = 1.7617004227970863;
            this.xrTableCell3.Name = "xrTableCell3";
            this.xrTableCell3.StylePriority.UseTextAlignment = false;
            this.xrTableCell3.Text = "CỘNG H\x00d2A X\x00c3 HỘI CHỦ NGHĨA VIỆT NAM";
            this.xrTableCell3.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableCell3.Weight = 1.2382995772029137;
            this.xrTableRow2.Cells.AddRange(new XRTableCell[] { this.txtContractCode, this.xrTableCell4 });
            this.xrTableRow2.Name = "xrTableRow2";
            this.xrTableRow2.Weight = 1.0416667175292968;
            this.txtContractCode.Font = new Font("Times New Roman", 9.75f, FontStyle.Bold);
            this.txtContractCode.Name = "txtContractCode";
            this.txtContractCode.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.txtContractCode.StylePriority.UseFont = false;
            this.txtContractCode.StylePriority.UsePadding = false;
            this.txtContractCode.StylePriority.UseTextAlignment = false;
            this.txtContractCode.Text = "Số: [ContractCode]";
            this.txtContractCode.TextAlignment = TextAlignment.MiddleLeft;
            this.txtContractCode.Weight = 1.7617001927409941;
            this.xrTableCell4.Multiline = true;
            this.xrTableCell4.Name = "xrTableCell4";
            this.xrTableCell4.StylePriority.UseTextAlignment = false;
            this.xrTableCell4.Text = "\tĐộc lập - Tự do - Hạnh ph\x00fac";
            this.xrTableCell4.TextAlignment = TextAlignment.MiddleLeft;
            this.xrTableCell4.Weight = 1.2382998072590059;
            this.xrTable3.LocationFloat = new PointFloat(9.536743E-05f, 1929.5f);
            this.xrTable3.Name = "xrTable3";
            this.xrTable3.Rows.AddRange(new XRTableRow[] { this.xrTableRow3, this.xrTableRow4 });
            this.xrTable3.SizeF = new SizeF(686.9999f, 62.5f);
            this.xrTableRow3.Cells.AddRange(new XRTableCell[] { this.xrTableCell7, this.xrTableCell8, this.xrTableCell9 });
            this.xrTableRow3.Name = "xrTableRow3";
            this.xrTableRow3.Weight = 1.0;
            this.xrTableCell7.Font = new Font("Times New Roman", 9.75f, FontStyle.Bold);
            this.xrTableCell7.Name = "xrTableCell7";
            this.xrTableCell7.StylePriority.UseFont = false;
            this.xrTableCell7.StylePriority.UseTextAlignment = false;
            this.xrTableCell7.Text = "Người lao động";
            this.xrTableCell7.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableCell7.Weight = 1.0;
            this.xrTableCell8.Name = "xrTableCell8";
            this.xrTableCell8.Weight = 1.0;
            this.xrTableCell9.Font = new Font("Times New Roman", 9.75f, FontStyle.Bold);
            this.xrTableCell9.Name = "xrTableCell9";
            this.xrTableCell9.StylePriority.UseFont = false;
            this.xrTableCell9.StylePriority.UseTextAlignment = false;
            this.xrTableCell9.Text = "Người sử dụng lao động";
            this.xrTableCell9.TextAlignment = TextAlignment.MiddleCenter;
            this.xrTableCell9.Weight = 1.0;
            this.xrTableRow4.Cells.AddRange(new XRTableCell[] { this.xrTableCell10, this.xrTableCell11, this.xrTableCell12 });
            this.xrTableRow4.Name = "xrTableRow4";
            this.xrTableRow4.Weight = 1.0;
            this.xrTableCell10.Font = new Font("Times New Roman", 9.75f, FontStyle.Italic);
            this.xrTableCell10.Name = "xrTableCell10";
            this.xrTableCell10.StylePriority.UseFont = false;
            this.xrTableCell10.StylePriority.UseTextAlignment = false;
            this.xrTableCell10.Text = "(K\x00fd v\x00e0 ghi r\x00f5 họ t\x00ean)";
            this.xrTableCell10.TextAlignment = TextAlignment.TopCenter;
            this.xrTableCell10.Weight = 1.0;
            this.xrTableCell11.Name = "xrTableCell11";
            this.xrTableCell11.Weight = 1.0;
            this.xrTableCell12.Font = new Font("Times New Roman", 9.75f, FontStyle.Italic);
            this.xrTableCell12.Name = "xrTableCell12";
            this.xrTableCell12.StylePriority.UseFont = false;
            this.xrTableCell12.StylePriority.UseTextAlignment = false;
            this.xrTableCell12.Text = "(K\x00fd v\x00e0 ghi r\x00f5 họ t\x00ean)";
            this.xrTableCell12.TextAlignment = TextAlignment.TopCenter;
            this.xrTableCell12.Weight = 1.0;
            this.TopMargin.HeightF = 50f;
            this.TopMargin.Name = "TopMargin";
            this.TopMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.TopMargin.TextAlignment = TextAlignment.TopLeft;
            this.BottomMargin.HeightF = 56f;
            this.BottomMargin.Name = "BottomMargin";
            this.BottomMargin.Padding = new PaddingInfo(0, 0, 0, 0, 100f);
            this.BottomMargin.TextAlignment = TextAlignment.TopLeft;
            this.formattingRule6.Name = "formattingRule6";
            base.Bands.AddRange(new Band[] { this.Detail, this.TopMargin, this.BottomMargin });
            base.Font = new Font("Times New Roman", 9.75f);
            base.FormattingRuleSheet.AddRange(new FormattingRule[] { this.formattingRule1, this.formattingRule2, this.formattingRule3, this.formattingRule4, this.formattingRule5, this.formattingRule6, this.formattingRule7, this.formattingRule8 });
            base.Margins = new Margins(90, 50, 50, 0x38);
            base.PageHeight = 0x491;
            base.PageWidth = 0x33b;
            base.PaperKind = PaperKind.A4;
            base.ScriptsSource = "\r\nprivate void xrRichText1_HtmlItemCreated(object sender, DevExpress.XtraReports.UI.HtmlEventArgs e) {\r\n\r\n}\r\n";
            base.Version = "9.3";
            this.BeforePrint += new PrintEventHandler(this.rptContract_BeforePrint);
            this.xrRichText1.EndInit();
            this.xrTable1.EndInit();
            this.xrTable3.EndInit();
            this.EndInit();
        }

        private void LoadAllData()
        {
            DataSet set = new DataSet();
            DataTable list = new DataTable();
            list = this.l_Contract.GetList(MyLogin.Level, MyLogin.Code);
            set.Tables.Add(list);
            base.DataSource = set;
            base.DataMember = list.TableName;
            base.DataAdapter = list;
        }

        private void LoadData()
        {
            DataSet set = new DataSet();
            DataTable listByContract = new DataTable();
            listByContract = this.l_Contract.GetListByContract(this.m_ContractCode, this.m_EmployeeCode);
            set.Tables.Add(listByContract);
            base.DataSource = set;
            base.DataMember = listByContract.TableName;
            base.DataAdapter = listByContract;
        }

        private void rptContract_BeforePrint(object sender, PrintEventArgs e)
        {
            ////if (MyInfo.Get(MyEncryption.Encrypt("ERP01", "123654", true)) == "OK")
            {
                this.txtCompany.Text = "";//MyInfo.Company.ToUpper();
            }
            if (this.m_EmployeeCode == "")
            {
                this.LoadAllData();
            }
            else
            {
                this.LoadData();
            }
        }
    }
}

